package com.apexedu.portal.controller;

import com.apexedu.biz.Const;
import com.apexedu.biz.entity.TServiceSatisfaction;
import com.apexedu.framework.dao.BaseDao;
import com.apexedu.framework.util.DBUtil;
import com.apexedu.framework.util.Pager;
import com.apexedu.framework.util.SeqFactory;
import com.apexedu.identity.IdConstants;
import com.apexedu.identity.entity.TSysMenu;
import com.apexedu.identity.entity.TSysUser;
import com.apexedu.portal.constant.ActionConstant;
import com.apexedu.portal.entity.*;
import com.apexedu.portal.service.impl.MhShdServiceImpl;
import com.apexedu.portal.util.DBMUtil;
import com.apexedu.portal.util.LittleTimer;
import com.apexedu.sys.entity.TSysCode;
import com.apexedu.sys.entity.TSysReportfactory;
import com.apexedu.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 门户4.0展示界面 山东大学
 * Created by ly on 2015/3/5.
 */
@Controller
public class MhSddxController extends BaseController {

    @Autowired
    BaseDao baseDao;
    @Resource
    private MhShdServiceImpl service;

    private static final String[] weeks = new String[]{"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
    public static final SimpleDateFormat FORMAT_DATE = new SimpleDateFormat("yyyy-MM-dd");
    private StringBuffer lm=new StringBuffer();
    private StringBuffer lmbh=new StringBuffer();
    private Integer group_num=0;
    private Integer analysis_num=0;
    HashMap<String,String> id_name_list = new HashMap<String,String>();
    HashMap<String,String[]> id_value_list = new HashMap<String,String[]>();

    HashMap<String,String[]> key_value_list = new HashMap<String,String[]>();
    /**
     * 初始界面
     *
     * @return 初始界面
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_init, method = RequestMethod.GET)
    public String init(HttpServletRequest request) {
        debug("<<{}>> init start", this.getClass().getSimpleName());
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        LittleTimer timer = new LittleTimer();
        try {
//            String type = getUsertype(request); //获取用户类型
//            initFwzx(request, type); //初始化服务咨询
//            initDyfw(request, type); //初始化订阅服务
//            initLcxx(request, user, ActionConstant.Process_Charge);//初始化代办流程
//            initLcxx(request,user,ActionConstant.Process_Initiate);//初始化发起流程
//            initLcxx(request,user,ActionConstant.Process_Participate);//初始化参与流程
//            initLcxx(request,user,ActionConstant.Process_Reply);//初始化回复流程
//            initMessage(request,user,ActionConstant.Process_Charge); //初始化订阅服务
//            List <TMessage> ls_oa= getMessage(request,user,"unread","oa",5);
//            List <TMessage> ls_hr= getMessage(request,user,"unread","hr",5);
//            request.setAttribute("ls_oa", ls_oa);
//            request.setAttribute("ls_hr", ls_hr);
//            return ActionConstant.MhShd.Forward_init;
            return "portal/shd/index";
        } catch (Exception e) {
            error("<<{}>> init error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> init end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 个人主页初始界面
     *
     * @return 初始界面
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_personal_homepage, method = RequestMethod.GET)
    public String personalHomepage(HttpServletRequest request) {
        debug("<<{}>> init start", this.getClass().getSimpleName());
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        LittleTimer timer = new LittleTimer();
        try {
            String type = getUsertype(request); //获取用户类型
            initFwzx(request, type); //初始化服务咨询
            initDyfw(request, type); //初始化订阅服务
            initLcxx(request, user, ActionConstant.Process_Charge);//初始化代办流程
            initLcxx(request,user,ActionConstant.Process_Initiate);//初始化发起流程
            initLcxx(request,user,ActionConstant.Process_Participate);//初始化参与流程
            initLcxx(request,user,ActionConstant.Process_Reply);//初始化回复流程
            initMessage(request,user,ActionConstant.Process_Charge); //初始化订阅服务
            List <TMessage> ls_oa= getMessage(request,user,"unread","oa",5);
            List <TMessage> ls_hr= getMessage(request,user,"unread","hr",5);
            request.setAttribute("ls_oa", ls_oa);
            request.setAttribute("ls_hr", ls_hr);
            return ActionConstant.MhShd.Forward_personal_homepage;
        } catch (Exception e) {
            error("<<{}>> init error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> init end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }
    /**
     * 初始化服务资源
     *
     * @param request --
     */
    private void initDyfw(HttpServletRequest request, String type) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String dyfwid = "dyfw";
//        if (Constants.MhUserType.XS.equals(type)) { //学生站点
//            dyfwid = "dyfwxs";
//        }
        request.setAttribute("dyfw", getDyfwList(user.getUserloginid(), dyfwid));
        request.setAttribute("dyfwid", dyfwid);
        request.setAttribute("userid", user.getUserloginid());
    }

    /**
     * 初始化消息
     *
     * @param request
     */
    private void initMessage(HttpServletRequest request,TSysUser user, String uid) {
        String sql_message="";
//        String sql = " select t.wid,t.messagename,(select code from t_db where wid=t.code) as code,t.querysql,t.applicablerole,t.shuom,t.state,t.accessurl " +
//                     " from T_USER_MESSAGEFACTORY t " +
//                     "  where t.APPLICABLEROLE like '%" + user.getUsertype() + "%' ";
        String insertsql="  insert into t_message(wid,bt,nr,url,zt,userid,ly,type,broadcastusers,sj)" +
                "  select sys_guid(),t.title,t.title,t.url,'unread',t.userid,t.db,'user','',sysdate" +
                "  from t_lbxx_mx t " +
                "  where not exists (select 1 from t_message m where m.url=t.url) and t.userid=? and t.processtype=?";
        String  selsql= "  select count(*) from t_message where zt=? and userid=?";
        DBUtil.executeSQL(insertsql, user.getUserloginid(), uid);
        long c = DBUtil.count(selsql, "unread", user.getUserloginid());
        request.setAttribute("messagenum",Long.toString(c));
    }

    /**
     * 初始化服务咨询
     *
     * @param request
     */
    private void initFwzx(HttpServletRequest request, String type) throws Exception {
        request.setAttribute("fwzx", getTzgg(new DBMUtil(), null, "select t.wid as id,t.pproblem as title,t.ptime as time,t.sid as id from t_PROBLEM t where t.state=1 and rownum <7 order by t.ptime desc"));
    }






    /**
     * 初始化流程信息
     *
     * @param request
     */
    private void initLcxx(HttpServletRequest request,TSysUser user, String upid)  {
        TDb tdb = new TDb();
        //查询该用户该位置有无添加报表
        String insertsql = "insert into T_Lbxx_Mx(wid,id,url,title,time,state,processtype,userid,db) select sys_guid(),?,?,?,?,?,?,?,? from dual";
        String delsql = "delete T_Lbxx_Mx where processtype=? and userid=?";
        String selsql = "select count(*) from T_Lbxx_Mx where processtype=? and userid=?";
        List<TLbxx> lbxxList = DBUtil.queryAllBeanList("select * from t_lbxx where state=1 and upid='" + upid + "' order by orderno", TLbxx.class);
        List<TLbxxMx> lbxxes = new ArrayList<TLbxxMx>();
        if (!lbxxList.isEmpty()) {
            for (TLbxx lbxx : lbxxList) {
                try {
                    lbxxes.addAll(new DBMUtil(lbxx.getDb()).queryAllBeanList(lbxx.getSql().replaceAll("\\{userid\\}", user.getUserloginid()).replaceAll("\\{db\\}", lbxx.getDb()), TLbxxMx.class));
                } catch (Exception e) {
                    error("<<{}>> initLcxx error : {}", this.getClass().getSimpleName(), e);
                    throw new RuntimeException(e);
                }
            }
        }
        if (lbxxes != null && lbxxes.size() > 0&&upid.equals(ActionConstant.Process_Charge)) {
            DBUtil.executeSQL(delsql, upid, user.getUserloginid());
            for (int i = 0; i < lbxxes.size(); i++) {
                TLbxxMx tlbxxmx = lbxxes.get(i);
                DBUtil.executeSQL(insertsql, tlbxxmx.getId(), tlbxxmx.getUrl(), tlbxxmx.getTitle(), tlbxxmx.getTime(), tlbxxmx.getState(), upid, user.getUserloginid(), tlbxxmx.getDb());
            }
        }
    }
    /**
     * 初始化日程信息
     *
     * @param request --
     */
    public void initRc(HttpServletRequest request) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        try {
            String sql = "select t.begintime,t.location,t.title from TSCHEDULE t left join tuser a on t.creator=a.id where a.userid=?" +
                    " and (to_date(to_char(sysdate,'yyyyMMdd'),'yyyyMMdd')" +
                    " between to_date(to_char(t.begindate,'yyyyMMdd'),'yyyyMMdd') and to_date(to_char(t.enddate,'yyyyMMdd'),'yyyyMMdd') )";
            List<Schedule> list = new DBMUtil("oa").queryAllBeanList(sql, Schedule.class, user.getUserloginid());
            request.setAttribute("rcap", list);
        } catch (Exception e) {
            error("<<{}>> initLczx error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        }
    }

    /**
     * 初始化流程中心
     *
     * @param request --
     */
    private void initLczx(HttpServletRequest request) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        List<TLbxx> lbxxList = DBUtil.queryAllBeanList("select * from t_lbxx where state=1 and upid=5 order by orderno", TLbxx.class);
        List<Lbxx> lbxxes = new ArrayList<Lbxx>();
        if (!lbxxList.isEmpty()) {
            for (TLbxx lbxx : lbxxList) {
                try {
                    lbxxes.addAll(new DBMUtil(lbxx.getDb()).queryAllBeanList(lbxx.getSql().replaceAll("\\{userid\\}", user.getUserloginid()), Lbxx.class));
                } catch (Exception e) {
                    error("<<{}>> initLczx error : {}", this.getClass().getSimpleName(), e);
                    throw new RuntimeException(e);
                }
            }
        }
        request.setAttribute("lczx", lbxxes);
    }

    /**
     * 周会议
     *
     * @return 周会议html代码
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_getZhy, method = RequestMethod.GET)
    @ResponseBody
    public String getZhy() {
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbutil = new DBMUtil("oa");
            /**
             * 查询OA数据库
             * t_zc 表
             * @参数 mc 名称
             * */
            String str = (String) dbutil.queryFieldValue("select zc.mc from t_zc zc where to_date(to_char(sysdate,'yyyyMMdd'),'yyyy-MM-dd') between ksrq and jsrq");
            String mc = str != null ? str : null;
            if (mc == null) {
//                throw new RuntimeException("一周会议无法获取周次名称!");
            }
            debug("<<{}>> doView : zc : {}", this.getClass().getSimpleName(), mc);

            String sql = "select (select decode( to_char(min(gg.kssj),'D'),1,7,to_char(min(gg.kssj),'D')-1) from dual)week ,  " +
                    "'<span><strong>会议内容：</strong>' || ap.hynr ||  '</span><br><span><strong>会议室：</strong>'  " +
                    "|| (select wm_concat(hys.hytmc) from OA_T_HWGL_HYSGL hys " +
                    " where hys.id in (select hysap.ncyhys  from OA_T_HWGL_HYAPB_HYSSYSJ hysap where hysap.oa_t_hwgl_hyapb_id = ap.id)) " +
                    " || '</span><br><span><strong>责任部门：</strong>' ||  " +
                    "(select wm_concat(b.NAME) from lborganization b where b.ID in (select * from table(split(ap.zbdw, ';'))))  ||  " +
                    " '</span><br><span><strong>活动召集人：</strong>' || (select u.NAME from tuser u where u.id = ap.sqr) " +
                    " || '</span><br><span><strong>时间：</strong>' ||  (select to_char(gg.kssj, 'hh24:mi:ss') || '-' " +
                    "|| to_char(gg.jssj, 'hh24:mi:ss') from dual)  || '</span><br><span><strong>参加领导：</strong>' " +
                    "|| (select wm_concat(uu.NAME)  from tuser uu where instr(';'||ap.chld||';', ';'||uu.id||';') > 0) " +
                    " || '</span><br><span><strong>参加人员：</strong>' || " +
                    " (select wm_concat(uu.NAME) from tuser uu where instr(';'||ap.yhry||';', ';'||uu.id||';') > 0) " +
                    " || '</span><br><span><strong>与会角色：</strong>' || " +
                    " (select wm_concat(qq.NAME)  from lbrole qq where instr(';'||ap.yhjs||';', ';'||qq.id||';') > 0) " +
                    " || '</span><br><span><strong>与会部门：</strong>' || " +
                    " (select wm_concat(vv.NAME) from lborganization vv where instr(';'||ap.yhbm||';', ';'||vv.id||';') > 0) " +
                    " || '</span><br><span><strong>校外来宾：</strong>' || ap.xwlb || '</span>' as nr  from OA_T_HWGL_HYAPB ap " +
                    " left join t_zc zc  on zc.id = ap.zc left join OA_T_HWGL_HYAPB_HYSSYSJ gg on ap.id=gg.oa_t_hwgl_hyapb_id" +
                    " where to_date(to_char(sysdate, 'yyyyMMdd'), 'yyyyMMdd')  between zc.ksrq and  zc.jsrq group by" +
                    " (gg.kssj,ap.hynr,ap.zbdw, ap.sqr,gg.jssj,ap.chld,ap.yhry,ap.xwlb,ap.id,ap.sqrq,ap.yhjs,ap.yhbm ) order by ap.sqrq, ap.id ";

            List<Map<String, Object>> list = dbutil.queryForList(null, sql);
            StringBuffer sb = new StringBuffer("");
            for (int i = 0; i < 12; i++) {
                sb.append("<tr>");
                for (int j = 1; j <= 7; j++) {
                    sb.append("<td>");
                    for (Map<String, Object> map : list) {
                        if (j == Integer.parseInt(map.get("week").toString())) {
                            debug("<<{}>> doView : week : {}", this.getClass().getSimpleName(), map.get("week"));
                            sb.append("<div  titleDesc=\"" + map.get("nr") + "\"style=color:white;>※</div>");
                            debug("<<{}>> doView : nr : {}", this.getClass().getSimpleName(), map.get("nr"));
                            list.remove(map);
                            break;
                        }
                    }
                    sb.append("</td>");
                }
                sb.append("</tr>");
            }
            return sb.toString();
        } catch (Exception e) {
            error("<<{}>> getZhy error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getZhy end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

    /**
     * 通知公告明细界面
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_noticeDetail, method = RequestMethod.GET)
    public String noticeDetail(@PathVariable(ActionConstant.Mh.Variable_db) String db,
                               @PathVariable(ActionConstant.Variable_Id) String id,
                               ModelMap map) {
        debug("<<{}>> noticeDetail start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            DBMUtil dbmUtil = new DBMUtil(db);
            Tblog blog = dbmUtil.queryBean("select b.*, to_char(b.pubtime, 'yyyy-MM-dd') as fbsj from tblog b where b.id =?", Tblog.class, id);
            //查询所有附件
            List<Lbnewsattachment> attach = dbmUtil.queryAllBeanList("select * from LBNEWSATTACHMENT where tblog_id =?", Lbnewsattachment.class, id);
            blog.setAttach(attach);
//            String content = blog.getContent().replaceAll("<span[^>]*>", "<span>").replaceAll("<div[^>]*>", "<div>");
//            blog.setContent(content);
            map.put("blog", blog);
            return ActionConstant.MhShd.Forward_noticeDetail;
        } catch (Exception e) {
            error("<<{}>> noticeDetail error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> noticeDetail end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }


    /**
     * 套用frame界面
     *
     * @return 套用frame界面
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_frame, method = RequestMethod.GET)
    public String frame(HttpServletRequest request, ModelMap map) {
        debug("<<{}>> frame start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        try {
            map.put("no", request.getParameter("no")); //选中二级菜单的索引
            map.put("url", request.getParameter("q"));
            return ActionConstant.MhShd.Forward_frame;
        } catch (Exception e) {
            error("<<{}>> frame error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> frame end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }
    public void initchar(){
        lm=new StringBuffer();
        lmbh=new StringBuffer();
        group_num=0;
        analysis_num=0;
        id_name_list = new HashMap<String,String>();
        id_value_list = new HashMap<String,String[]>();
        key_value_list = new HashMap<String,String[]>();
    }

    /**
     * 整理分组条件，把分组名称加入lm中
     *
     * @param groupingconditions
     * @return
     */
    public void getGroupingconditions(String groupingconditions){
        String[] idname;
        String[] groupteam =groupingconditions.split(";");
        if (groupteam!=null&&groupteam.length>0){
            group_num=groupteam.length;
            for (int i=0;i<groupteam.length;i++){
                idname= groupteam[i].split("=");
                if(idname!=null&&idname.length==2) {
                    lm.append(idname[0] + ",");
                    lmbh.append("value" + i + ",");
                    id_name_list.put("value" + i, idname[0]);
                    id_value_list.put("value" + i, idname[1].split(","));
                }
            }
        }
    }
    /**
     * 整理分析项，把分析项名称加入lm中
     *
     * @param analysisofitem
     * @return
     */
    public void getAnalysisofitem(String analysisofitem){
        String[] analysisteam =analysisofitem.split(",");
        if (analysisteam!=null&&analysisteam.length>0){
            analysis_num=analysisteam.length;
            for (int i=0;i<analysisteam.length;i++){
                lm.append(analysisteam[i]+",");
                lmbh.append("num" + i+ ",");
            }
        }
    }

    /**
     * 查看图集的详细内容
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/uc/shd/tj-{location}({height})", method = RequestMethod.GET)
    public synchronized String queryEntity(@PathVariable String location, @PathVariable String height,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> tj start", this.getClass().getSimpleName());
        List<String[]> al_new = new ArrayList<String[]>();
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        TSysReportfactory reportfactory =new TSysReportfactory();
        //查询该用户该位置有无添加报表
        String sql_ur=" select wid,rwid,userid,location " +
                " from t_user_report "+
                " where 1=1 and location=? and userid=?";
        //查询该用户该位置报表工厂内容
        String sql_rf=" select t.wid,t.chartname,(select code from t_db where wid=t.code) as code,t.querysql,t.charttype,t.analysisofitem,t.groupingconditions " +
                " from t_sys_reportfactory t "+
                " where 1=1 and wid=?";
        List<TUserReport> userReportlist = DBUtil.queryAllBeanList(sql_ur, TUserReport.class, location, user.getUserid());
        if (userReportlist!=null&& userReportlist.size()>0){
            TUserReport userReport =userReportlist.get(0);
            if (userReport!=null&&StringUtil.isNotBlank(userReport.getRwid())){
                reportfactory= DBUtil.queryBean(sql_rf, TSysReportfactory.class, userReport.getRwid());
                al_new=searchData(reportfactory);
                //如果展示方式是图，整理数据，并生成对应Json
                if (!"list".equals(reportfactory.getCharttype())){
                    al_new=formatDate(reportfactory);
                    charDate(request,reportfactory,al_new);
                }else{
                    al_new=formatDateforlist(reportfactory);
                    String title=reportfactory.getChartname();
                    request.setAttribute("title", title);
                    request.setAttribute("resultData", al_new);
                    request.setAttribute("lm", lm.toString().split(","));
                    request.setAttribute("lmbh", lmbh.toString().split(","));
                }
                request.setAttribute("location", location);
                request.setAttribute("height", height);
                //根据图类型调转不同的页面
                return "portal/shd/tj/"+reportfactory.getCharttype()+"chart";
            }else {
                request.setAttribute("height", height);
                return "portal/shd/tj/" + location + "_add";
            }
        }else{
            return "portal/shd/tj/"+location+"_add";
        }
    }

    /**
     * 图集预览
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/uc/shd/yl-{wid}({height})", method = RequestMethod.GET)
    public String queryYl(@PathVariable String wid,@PathVariable String height, HttpServletRequest request, ModelMap map) {
        debug("<<{}>> tj start", this.getClass().getSimpleName());
        List<String[]> al_new = new ArrayList<String[]>();
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        TSysReportfactory reportfactory =new TSysReportfactory();
        //查询该用户该位置报表工厂内容
        String sql_rf=  " select t.wid,t.chartname,(select code from t_db where wid=t.code) as code,t.querysql,t.charttype,t.analysisofitem,t.groupingconditions " +
                " from t_sys_reportfactory t "+
                " where 1=1 and wid=?";
        reportfactory= DBUtil.queryBean(sql_rf, TSysReportfactory.class, wid);
        al_new=searchData(reportfactory);
        //如果展示方式是图，整理数据，并生成对应Json
        if (!"list".equals(reportfactory.getCharttype())){
            al_new=formatDate(reportfactory);
            charDate(request,reportfactory,al_new);
        }else{
            al_new=formatDateforlist(reportfactory);
            String title=reportfactory.getChartname();
            request.setAttribute("title", title);
            request.setAttribute("resultData", al_new);
            request.setAttribute("lm", lm.toString().split(","));
            request.setAttribute("lmbh", lmbh.toString().split(","));
        }
        request.setAttribute("height", height);
        //根据图类型调转不同的页面
        return "portal/shd/tj/"+reportfactory.getCharttype()+"chart";
    }

    /**
     *查询数据，并存入al_new
     *
     */
    private List<String[]> searchData(TSysReportfactory reportfactory){
        List<String[]> al_new = new ArrayList<String[]>();
        initchar();
        getGroupingconditions(reportfactory.getGroupingconditions());
        getAnalysisofitem(reportfactory.getAnalysisofitem());
        TDb t_db=new TDb();
        String codeid=reportfactory.getCode();
        String sql = reportfactory.getQuerysql();
        DBMUtil dbmUtil = new DBMUtil(reportfactory.getCode());
        ResultSet rs = dbmUtil.queryRowSet(reportfactory.getCode(),sql);
        String[] key=lmbh.toString().split(",");
        try {
            while(rs.next()){
                String[] newline = new String[key.length];
                String resultskey="";
                for (int i=0;i<key.length;i++){
                    newline[i] = rs.getString(i+1);
                    if (i<group_num) {
                        resultskey+=newline[i]+"_";
                    }
                }
                if (resultskey.length()>0){
                    resultskey= resultskey.substring(0,resultskey.length()-1);
                }
                key_value_list.put(resultskey,newline);
                al_new.add(newline);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return al_new;
    }



    /**
     * 整理数据集，补充未结果的数据
     *
     * @param reportfactory
     * @return
     */
    private List<String[]> formatDate(TSysReportfactory reportfactory) {
        int lengthline=group_num+analysis_num;
        List<String[]> al_new = new ArrayList<String[]>();
        if (group_num==1){
            String[] idvalue=id_value_list.get("value0");
            for (int n=0;n<idvalue.length;n++){
                if (key_value_list.get(idvalue[n])!=null){
                    String[] temp=(String[]) key_value_list.get(idvalue[n]);
                    String[] newline = new String[analysis_num];
                    for (int m=group_num;m<temp.length;m++){
                        newline[m-group_num]=temp[m]!=null?temp[m].toString():"";
                    }
                    al_new.add(newline);
                }else{
                    String[] newline = new String[analysis_num];
                    for (int m=0;m<analysis_num;m++){
                        newline[m]="";
                    }
                    al_new.add(newline);
                }
            }
        }
        if (group_num==2){
            String[] idvalue_1=id_value_list.get("value0");
            String[] idvalue_2=id_value_list.get("value1");
            for (int j=0;j<idvalue_1.length;j++){
                for (int n=0;n<idvalue_1.length;n++) {
                    if (key_value_list.get(idvalue_1[j]+"_"+idvalue_2[n]) != null) {
                        String[] temp=(String[]) key_value_list.get(idvalue_1[j]+""+idvalue_2[n]);
                        String[] newline = new String[analysis_num];
                        for (int m=2;m<temp.length;m++){
                            newline[m]=temp[m]!=null?temp[m].toString():"";
                        }
                        al_new.add(newline);
                    } else {
                        String[] newline = new String[analysis_num];
                        for (int m=2;m<lengthline;m++){
                            newline[m]="";
                        }
                        al_new.add(newline);
                    }
                }
            }
        }
        if (group_num==3){
            String[] idvalue_1=id_value_list.get("value0");
            String[] idvalue_2=id_value_list.get("value1");
            String[] idvalue_3=id_value_list.get("value2");
            for (int i=0;i<idvalue_1.length;i++){
                for (int j=0;j<idvalue_2.length;j++) {
                    for (int n=0;n<idvalue_3.length;n++) {
                        if (key_value_list.get(idvalue_1[i] + "_" +idvalue_2[j] + "_" + idvalue_3[n]) != null) {
                            String[] temp=(String[]) key_value_list.get(idvalue_1[i] + "_" +idvalue_2[j] + "_" + idvalue_3[n]);
                            String[] newline = new String[analysis_num];
                            for (int m=3;m<temp.length;m++){
                                newline[m]=temp[m]!=null?temp[m].toString():"";
                            }
                            al_new.add(newline);
                        } else {
                            String[] newline = new String[analysis_num];
                            for (int m=3;m<lengthline;m++){
                                newline[m]="";
                            }
                            al_new.add(newline);
                        }
                    }
                }
            }
        }
        return al_new;
    }
    /**
     * 整理数据集，补充未结果的数据
     *
     * @param reportfactory
     * @return
     */
    private List<String[]> formatDateforlist(TSysReportfactory reportfactory) {
        int lengthline=group_num+analysis_num;
        List<String[]> al_new = new ArrayList<String[]>();
        if (group_num==1){
            String[] idvalue=id_value_list.get("value0");
            for (int n=0;n<idvalue.length;n++){
                if (key_value_list.get(idvalue[n])!=null){
                    String[] temp=(String[]) key_value_list.get(idvalue[n]);
                    al_new.add(temp);
                }else{
                    String[] newline = new String[lengthline];
                    newline[0]=idvalue[n];
                    for (int m=group_num;m<lengthline;m++){
                        newline[m]="";
                    }
                    al_new.add(newline);
                }
            }
        }
        if (group_num==2){
            String[] idvalue_1=id_value_list.get("value0");
            String[] idvalue_2=id_value_list.get("value1");
            for (int j=0;j<idvalue_1.length;j++){
                for (int n=0;n<idvalue_1.length;n++) {
                    if (key_value_list.get(idvalue_1[j]+"_"+idvalue_2[n]) != null) {
                        String[] temp=(String[]) key_value_list.get(idvalue_1[j]+""+idvalue_2[n]);
                        al_new.add(temp);
                    } else {
                        String[] newline = new String[lengthline];
                        newline[0]=idvalue_1[j];
                        newline[1]=idvalue_2[n];
                        for (int m=group_num;m<lengthline;m++){
                            newline[m]="";
                        }
                        al_new.add(newline);
                    }
                }
            }
        }
        if (group_num==3){
            String[] idvalue_1=id_value_list.get("value0");
            String[] idvalue_2=id_value_list.get("value1");
            String[] idvalue_3=id_value_list.get("value2");
            for (int i=0;i<idvalue_1.length;i++){
                for (int j=0;j<idvalue_2.length;j++) {
                    for (int n=0;n<idvalue_3.length;n++) {
                        if (key_value_list.get(idvalue_1[i] + "_" +idvalue_2[j] + "_" + idvalue_3[n]) != null) {
                            String[] temp=(String[]) key_value_list.get(idvalue_1[i] + "_" +idvalue_2[j] + "_" + idvalue_3[n]);
                            al_new.add(temp);
                        } else {
                            String[] newline = new String[lengthline];
                            newline[0]=idvalue_1[i];
                            newline[1]=idvalue_2[j];
                            newline[2]=idvalue_2[n];
                            for (int m=group_num;m<lengthline;m++){
                                newline[m]="";
                            }
                            al_new.add(newline);
                        }
                    }
                }
            }
        }
        return al_new;
    }

    /**
     * 把查询的记录集格式化为输出的样式
     *
     * @param reportfactory
     * @return
     */
    private void charDate(HttpServletRequest request,TSysReportfactory reportfactory,List<String[]> al_list) {
        String title=reportfactory.getChartname();;
        String categories="";
        String[] temp=lm.toString().split(",");
        String yAxis="";
        String series="";
        String pointStart="";
        String charttype =reportfactory.getCharttype();
        if ("column".equals(charttype)){
            String[] categories_temp=id_value_list.get("value0");
            for (int i=0;i<categories_temp.length;i++){
                categories+=categories_temp[i]+"," ;
            }
            if (categories.length()>0){
                categories=categories.substring(0,categories.length()-1);
            }
            if (temp!=null&&temp.length>group_num){
                yAxis=temp[group_num];
            }
            series=getJsonValue(reportfactory,categories_temp,al_list);
        }
        if ("area".equals(charttype)){
            String[] categories_temp=id_value_list.get("value0");
            if (categories_temp!=null&&categories_temp.length>0){
                pointStart=categories_temp[0];
            }
            if (temp!=null&&temp.length>group_num){
                yAxis=temp[group_num];
            }
            series=getJsonValue(reportfactory,categories_temp,al_list);
        }
        if ("line".equals(charttype)){
            String[] categories_temp=id_value_list.get("value0");
            for (int i=0;i<categories_temp.length;i++){
                categories+=categories_temp[i]+"," ;
            }
            if (categories.length()>0){
                categories=categories.substring(0,categories.length()-1);
            }
            if (temp!=null&&temp.length>group_num){
                yAxis=temp[group_num];
            }
            series=getJsonValue(reportfactory,categories_temp,al_list);
        }
        if ("pie".equals(charttype)){
            String[] categories_temp=id_value_list.get("value0");
            series= getJsonValueforpic(reportfactory,categories_temp,al_list);
        }
        categories="'"+categories.replace(",","','")+"'";
        request.setAttribute("title", title);
        request.setAttribute("categories", categories);
        request.setAttribute("yAxis", yAxis);
        request.setAttribute("series", series);
        request.setAttribute("pointStart", pointStart);

    }

    /**
     * 根据sql返回json字符串
     *
     * @param reportfactory
     * @return
     */
    private String getJsonValue(TSysReportfactory reportfactory,String[] categories,List<String[]> al_list) {
        String[] analysisteam =reportfactory.getAnalysisofitem().split(",");
        StringBuffer sb = new StringBuffer();
        StringBuffer sb_temp = new StringBuffer();
        String[] groupteam =categories;
        for (int i=0;i<analysisteam.length;i++){
            sb.append("{name:'").append(analysisteam[i]).append("',");
            sb.append("data:[");
            for (int al_list_len=0;al_list_len<al_list.size();al_list_len++){
                String[] temp=al_list.get(al_list_len);
                sb_temp.append(temp[i]!=null&temp[i].length()>0?temp[i]:"0").append(",");
            }
            if (sb_temp.length()>0){
                sb_temp.deleteCharAt(sb_temp.length()-1);
            }
            sb.append(sb_temp.toString());
            sb.append("]},");
        }
        if (sb.length()>0){
            sb.deleteCharAt(sb.length() - 1);
        }

        return sb.toString();
    }

    /**
     * 根据sql返回json字符串
     *
     * @param reportfactory
     * @return
     */
    private String getJsonValueforpic(TSysReportfactory reportfactory,String[] categories,List<String[]> al_list) {
        int fx_num=0;
        String[] analysisteam =reportfactory.getAnalysisofitem().split(",");
        StringBuffer sb = new StringBuffer();
        StringBuffer sb_temp = new StringBuffer();
        String[] groupteam =categories;
        sb.append("{type: 'pie',name:'").append(analysisteam[0]).append("',");
        sb.append("data:[");
        for (int i=0;i<analysisteam.length;i++){
            if (i==fx_num) {
                for (int al_list_len = 0; al_list_len < al_list.size(); al_list_len++) {
                    String[] temp = al_list.get(al_list_len);
                    sb.append("['" + categories[al_list_len] + "',").append(temp[fx_num] != null & temp[fx_num].length() > 0 ? temp[fx_num] : "0").append("],");
                }
                if (sb.length() > 0) {
                    sb.deleteCharAt(sb.length() - 1);
                }
            }
        }
        sb.append("]}");
        return sb.toString();
    }
    /**
     * 查看图集的详细内容（四级页面）
     * @param map
     * @return
     */
    @RequestMapping(value = "/uc/shd/settj-{location}", method = RequestMethod.GET)
    public String choosereport(@PathVariable String location, HttpServletRequest request, ModelMap map) {
        debug("<<{}>> choosereport start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String sql_cr=" select t.wid,t.chartname,t.images,t.shuom " +
                " from T_SYS_REPORTFACTORY t " +
                " where 1=1 and t.state='1' and not exists (select 1 from t_user_report r where r.userid=? and r.rwid=t.wid )";
        List<TSysReportfactory> reportfactoryList = DBUtil.queryAllBeanList(sql_cr, TSysReportfactory.class, user.getUserid());
        request.setAttribute("reportfactoryList", reportfactoryList);
        request.setAttribute("location", location);
        return "portal/shd/tj/choosereport";
    }

    /**
     * 门户前台栏目配置内容展示
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/shd/fdn-{location}", method = RequestMethod.GET)
    public String queryNewsEntityNoNumber(@PathVariable String location,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> fdn start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        int rownum=6;
        List<TWz> al_new = new ArrayList<TWz>();
        TSysReportfactory reportfactory =new TSysReportfactory();
        TDb tdb =new TDb();
        Pager pager=new Pager();
        //查询该用户该位置有无添加报表
        String sql_fdn=" select t.wid,t.lmmc,(select code from t_db where wid=t.code) as code,t.querysql,t.weiz,t.shuom,t.state " +
                " from T_FRONTDESK_NEWS t"+
                " where 1=1 and t.weiz=? ";
        List<TFrontdeskNews> tfrontdesknewslist = DBUtil.queryAllBeanList(sql_fdn, TFrontdeskNews.class, location);
        if (tfrontdesknewslist!=null&& tfrontdesknewslist.size()>0){
            TFrontdeskNews tfrontdesknews =tfrontdesknewslist.get(0);
            request.setAttribute("tfrontdesknews", tfrontdesknews);
            String sql_new = tfrontdesknews.getQuerysql();
            DBMUtil dbmUtil = new DBMUtil(tfrontdesknews.getCode());
            tdb =DBUtil.queryBean("select * from t_db where code=? and rownum<2" ,TDb.class,tfrontdesknews.getCode());
            pager.setEachPageRows(rownum);
            try {
                if (tdb.getUrl().indexOf("sqlserver")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+") as t ");
                    pager.setTotalRows(c);
                }else if(tdb.getUrl().indexOf("oracle")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+")");
                    pager.setTotalRows(c);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        request.setAttribute("totalPages", pager.getTotalPages() + "");
        return "portal/shd/frontdesknews";
    }

    /**
     * 门户前台栏目配置内容展示
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/shd/fdn-{location}({rownum})", method = RequestMethod.GET)
    public String queryNewsEntity(@PathVariable String location,@PathVariable int rownum,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> fdn start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        List<TWz> al_new = new ArrayList<TWz>();
        TSysReportfactory reportfactory =new TSysReportfactory();
        TDb tdb =new TDb();
        Pager pager=new Pager();
        //查询该用户该位置有无添加报表
        String sql_fdn=" select t.wid,t.lmmc,(select code from t_db where wid=t.code) as code,t.querysql,t.weiz,t.shuom,t.state " +
                " from T_FRONTDESK_NEWS t"+
                " where 1=1 and t.weiz=? ";
        List<TFrontdeskNews> tfrontdesknewslist = DBUtil.queryAllBeanList(sql_fdn, TFrontdeskNews.class, location);
        if (tfrontdesknewslist!=null&& tfrontdesknewslist.size()>0){
            TFrontdeskNews tfrontdesknews =tfrontdesknewslist.get(0);
            request.setAttribute("tfrontdesknews", tfrontdesknews);
            String sql_new = tfrontdesknews.getQuerysql();
            DBMUtil dbmUtil = new DBMUtil(tfrontdesknews.getCode());
            tdb =DBUtil.queryBean("select * from t_db where code=? and rownum<2" ,TDb.class,tfrontdesknews.getCode());
            pager.setEachPageRows(rownum);
            try {
                if (tdb.getUrl().indexOf("sqlserver")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+") as t ");
                    pager.setTotalRows(c);
                }else if(tdb.getUrl().indexOf("oracle")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+")");
                    pager.setTotalRows(c);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        request.setAttribute("totalPages", pager.getTotalPages() + "");
        return "portal/shd/frontdesknews";
    }

    /**
     * 文章列表界面
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value = "/uc/shd/fdn/{location}", method = RequestMethod.GET)
    public String queryNewsPagesList(@PathVariable String location,HttpServletRequest request, ModelMap map, Pager pager,String gjz) {

        debug("<<{}>> queryNewsPagesList start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        List<TWz> list = Collections.EMPTY_LIST;
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        List <TMessage> ls_oa= getMessage(request, user, "unread", "oa", 5);
        List <TMessage> ls_hr= getMessage(request, user, "unread", "hr", 5);
        request.setAttribute("ls_oa", ls_oa);
        request.setAttribute("ls_hr", ls_hr);
        TDb tdb =new TDb();
        String sql_fdn = " select t.wid,t.lmmc,(select code from t_db where wid=t.code) as code,t.querysql,t.weiz,t.shuom,t.state " +
                " from T_FRONTDESK_NEWS t" +
                " where 1=1 and t.state=1 and t.weiz=? ";
        String conditions="";
        List<TFrontdeskNews> tfrontdesknewslist = DBUtil.queryAllBeanList(sql_fdn, TFrontdeskNews.class, location);
        if (tfrontdesknewslist != null && tfrontdesknewslist.size() > 0) {
            TFrontdeskNews tfrontdesknews = tfrontdesknewslist.get(0);
            request.setAttribute("tfrontdesknews", tfrontdesknews);
            String sql_new = tfrontdesknews.getQuerysql();
            if (StringUtil.isNotBlank(gjz)){
                request.setAttribute("gjz", gjz);
                try {
                    gjz=java.net.URLDecoder.decode(gjz, "UTF-8");
                    request.setAttribute("xs", gjz);
                    conditions=" and (title like '%"+gjz+"%' )";
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
            DBMUtil dbmUtil = new DBMUtil(tfrontdesknews.getCode());
            tdb =DBUtil.queryBean("select * from t_db where code=? and rownum<2" ,TDb.class,tfrontdesknews.getCode());
            pager.setEachPageRows(9);
            try {
                if (tdb.getUrl().indexOf("sqlserver")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+") as t "+conditions);
                    pager.setTotalRows(c);
                    String sql="select top "+pager.getEachPageRows()+" * from (" + sql_new + ") as t where 1=1  "+conditions+" and  wid not in (select top "+(pager.getCurrentPageno() - 1) * pager.getEachPageRows()+" wid from (" + sql_new + ") as s where 1=1 "+conditions+" ) " ;
                    list = dbmUtil.queryAllBeanList(sql,TWz.class);
                }else if(tdb.getUrl().indexOf("oracle")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+")"+conditions);
                    pager.setTotalRows(c);
                    list = dbmUtil.queryPageBeanList("select * from (" + sql_new + ") where 1=1 " + conditions, pager, TWz.class);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        request.setAttribute("resultList", list);
        return "portal/shd/frontdesknewslist";
    }

    /**
     * 文章明细界面
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value = "/uc/shd/fdnv/{location}-{wid}", method = RequestMethod.GET)
    public String queryNewsBean(@PathVariable String location,@PathVariable String wid,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> queryNewsBean start", this.getClass().getSimpleName());
        System.out.println("///////////////queryNewsBean///////////////////");
        LittleTimer timer = new LittleTimer();
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        List <TMessage> ls_oa= getMessage(request,user,"unread","oa",5);
        List <TMessage> ls_hr= getMessage(request, user, "unread", "hr", 5);
        request.setAttribute("ls_oa", ls_oa);
        request.setAttribute("ls_hr", ls_hr);
        TWz twz = new TWz();
        TDb tdb =new TDb();
        String sql_fdn = " select t.wid,t.lmmc,(select code from t_db where wid=t.code) as code,t.querysql,t.weiz,t.shuom,t.state,t.updatesql" +
                " from T_FRONTDESK_NEWS t" +
                " where 1=1 and t.state=1 and t.weiz=? ";
        List<TFrontdeskNews> tfrontdesknewslist = DBUtil.queryAllBeanList(sql_fdn, TFrontdeskNews.class, location);
        if (tfrontdesknewslist != null && tfrontdesknewslist.size() > 0) {
            TFrontdeskNews tfrontdesknews = tfrontdesknewslist.get(0);
            request.setAttribute("tfrontdesknews", tfrontdesknews);
            String sql_new = tfrontdesknews.getQuerysql();
            String update_sql=tfrontdesknews.getUpdatesql();
            DBMUtil dbmUtil = new DBMUtil(tfrontdesknews.getCode());
            tdb =DBUtil.queryBean("select * from t_db where code=? and rownum<2" ,TDb.class,tfrontdesknews.getCode());
            if (StringUtil.isNotBlank(update_sql)){
                try {
                    int i =dbmUtil.executeSQL(update_sql,wid);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (tdb.getUrl().indexOf("sqlserver")!=-1){
                sql_new = " select * from (" + sql_new + " )  as t where wid=?";
            }else if(tdb.getUrl().indexOf("oracle")!=-1){
                sql_new = " select * from (" + sql_new + " ) where wid=?";
            }
            try {
                System.out.println("sql_new=" + sql_new);
                twz = dbmUtil.queryBean(sql_new, TWz.class, wid);
            } catch (Exception e) {
                System.out.println("E=" +e.toString());
                e.printStackTrace();
            }
        }
        request.setAttribute("twz", twz);
        return "portal/shd/frontdesknewsDetail";
    }

    /**
     * 流程代码业务导航界面
     *
     * @param request --
     * @return workflowTypes
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_workflow, method = RequestMethod.GET)
    public String workflow(HttpServletRequest request) {
        debug("<<{}>> workflow start", this.getClass().getSimpleName());
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        List <TMessage> ls_oa= getMessage(request,user,"unread","oa",5);
        List <TMessage> ls_hr= getMessage(request, user, "unread", "hr", 5);
        request.setAttribute("ls_oa", ls_oa);
        request.setAttribute("ls_hr", ls_hr);
        LittleTimer timer = new LittleTimer();
        try {
            List<TLbxx> workflowTypes = DBUtil.queryAllBeanList("select * from t_lbxx t" +
                    " where t.lx = '1' and t.upid = '1' and t.state='1' order by orderno", TLbxx.class);
            List<TLbxx> workflows = DBUtil.queryAllBeanList("select lb.wid,lb.upid,lb.name," +
                    " db.link||'/StartWorkflow?PageOnly=true&Workflow='||lb.des as url from t_lbxx lb" +
                    " inner join t_sys_role_workflow  rw on lb.wid=rw.workflowid" +
                    " inner join t_sys_user_role ur on ur.roleid= rw.roleid" +
                    " inner join t_db db on db.code=lb.db" +
                    " where lb.lx=1 and lb.upid!='1' and ur.userid=?" +
                    " order by lb.upid,lb.orderno", TLbxx.class, user.getUserid());
            for (int i = 0; i < workflowTypes.size(); i++) {
                TLbxx workflowType = workflowTypes.get(i);
                for (TLbxx workflow : workflows) {
                    if (workflow.getUpid().equals(workflowType.getWid())) {
                        workflowType.getLbxxList().add(workflow);
                    }
                }
                if (workflowType.getLbxxList().isEmpty()) {
                    workflowTypes.remove(i);
                    i--;
                }
            }
            request.setAttribute("workflowTypes", workflowTypes);
            return ActionConstant.MhShd.Forward_workflow;
        } catch (Exception e) {
            error("<<{}>> workflow error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> workflow end : {}", this.getClass().getSimpleName(), timer.end());
        }
    }

     /**
     * 获取没读信息
     * @return 结果
     */
    @RequestMapping(value = "/shd/fdnv/unreadlist/{location}-{pages}", method = RequestMethod.POST)
    public @ResponseBody String fdnvreadlist(@PathVariable String location,@PathVariable int pages,HttpServletRequest request) {
        debug("<<{}>> queryNewsPagesList start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        StringBuffer sb= new StringBuffer();
        String datetime="";
        List<TWz> list = Collections.EMPTY_LIST;
        TDb tdb =new TDb();
        String sql_fdn = " select t.wid,t.lmmc,(select code from t_db where wid=t.code) as code,t.querysql,t.weiz,t.shuom,t.state " +
                " from T_FRONTDESK_NEWS t" +
                " where 1=1 and t.state=1 and t.weiz=? ";
        String conditions="";
        List<TFrontdeskNews> tfrontdesknewslist = DBUtil.queryAllBeanList(sql_fdn, TFrontdeskNews.class, location);
        if (tfrontdesknewslist != null && tfrontdesknewslist.size() > 0) {
            TFrontdeskNews tfrontdesknews = tfrontdesknewslist.get(0);
            request.setAttribute("tfrontdesknews", tfrontdesknews);
            String sql_new = tfrontdesknews.getQuerysql();
            DBMUtil dbmUtil = new DBMUtil(tfrontdesknews.getCode());
            tdb =DBUtil.queryBean("select * from t_db where code=? and rownum<2" ,TDb.class,tfrontdesknews.getCode());
            Pager pager =new Pager();
            pager.setEachPageRows(6);
            pager.setCurrentPageno(pages);
            try {
                if (tdb.getUrl().indexOf("sqlserver")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+") as t "+conditions);
                    pager.setTotalRows(c);
                    String sql="select top "+pager.getEachPageRows()+" * from (" + sql_new + ") as t where 1=1  "+conditions+" and  wid not in (select top "+(pager.getCurrentPageno() - 1) * pager.getEachPageRows()+" wid from (" + sql_new + ") as s where 1=1 "+conditions+" ) " ;
                    list = dbmUtil.queryAllBeanList(sql,TWz.class);
                }else if(tdb.getUrl().indexOf("oracle")!=-1){
                    long c = dbmUtil.count("select count(*) from ("+sql_new+")"+conditions);
                    pager.setTotalRows(c);
                    list = dbmUtil.queryPageBeanList("select * from (" + sql_new + ") where 1=1 " + conditions, pager, TWz.class);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        if (list!=null&&list.size()>0) {
            for (int i = 0; i < list.size(); i++) {
                TWz twz = list.get(i);
                if (twz.getCjrq()!=null){
                    datetime= FORMAT_DATE.format(twz.getCjrq());
                }else{
                    datetime="";
                }
                sb.append("<div class='li'><span onclick=\"gotoHtml('"+location+"-"+twz.getWid()+"')\"><a>" + twz.getTitle() + "</a></span><div class='time on'>" + datetime + "</div></div>");
            }
            if (list.size()<6){
                for (int i = list.size(); i <6; i++) {
                    sb.append("<div class='li'><span><a></a></span><div class='time on'></div></div>");
                }
            }
        }
        return sb.toString();
    }

    /**
     * 门户前台流程初始化
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/uc/shd/chargeprocess-{upid}({rownum})", method = RequestMethod.GET)
    public String queryChargeprocessEntity(@PathVariable String upid,@PathVariable int rownum,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> fdn start", this.getClass().getSimpleName());
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        Pager pager=new Pager();
        pager.setEachPageRows(rownum);
        String selsql="select count(*) from T_Lbxx_Mx where processtype=? and userid=?";
        long c = DBUtil.count(selsql, upid, user.getUserloginid());
        pager.setTotalRows(c);
        request.setAttribute("upid", upid);
        request.setAttribute("totalPages", pager.getTotalPages() + "");
        request.setAttribute("totalRows", pager.getTotalRows() +"");
        return "portal/shd/chargeprocess";
    }


    /**
     * 获取没读信息
     * @return 结果
     */
    @RequestMapping(value = "/uc/shd/fdnv/chargeprocess/{upid}-{pages}({rownum})", method = RequestMethod.POST)
    public @ResponseBody String chargeprocesslist(@PathVariable String upid,@PathVariable int pages,@PathVariable int rownum,HttpServletRequest request) {
        debug("<<{}>> queryNewsPagesList start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        StringBuffer sb= new StringBuffer();
        String datetime="";
        List<TLbxxMx> list = Collections.EMPTY_LIST;
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String selsql="select wid,id,url,title,time,state,processtype,userid,db from T_Lbxx_Mx where processtype=? and userid=? order by time desc,db desc";
        Pager pager =new Pager();
        long c = DBUtil.count("select count(*) from (" + selsql + ")", upid, user.getUserloginid());
        pager.setTotalRows(c);
        pager.setEachPageRows(rownum);
        pager.setCurrentPageno(pages);
        list = DBUtil.queryPageBeanList(pager,"select * from (" + selsql + ") where 1=1", TLbxxMx.class,upid,user.getUserloginid());
        if (list!=null&&list.size()>0) {
            for (int i = 0; i < list.size(); i++) {
                TLbxxMx tlbxxmx = list.get(i);
                if (tlbxxmx.getTime()!=null){
                    datetime= FORMAT_DATE.format(tlbxxmx.getTime());
                }else{
                    datetime="";
                }
                sb.append("<div class='li'><span onclick=\"gotoHtml('"+tlbxxmx.getUrl()+"')\"><a>" + tlbxxmx.getTitle() + "</a></span>");
                if ("oa".equals(tlbxxmx.getDb())) {
                    sb.append("<label class='xz'> OA办公 </label >");
                }else if ("hr".equals(tlbxxmx.getDb())){
                    sb.append("<label class='dz'> 人事 </label >");
                }else{
                    sb.append("<label class='hq'> 其他 </label >");
                }
                sb.append("<div class='time on'>" + datetime + "</div></div>");
            }
            if (list.size()<6){
                for (int i = list.size(); i <6; i++) {
                    sb.append("<div class='li'><span><a></a></span><div class='time on'></div></div>");
                }
            }
        }
        return sb.toString();
    }

    /**
     * 门户前台流程初始化
     *
     * @param map
     * @return
     */
    @RequestMapping(value = "/uc/shd/initiateprocess-{upid}({rownum})", method = RequestMethod.GET)
    public String queryInitiateprocessEntity(@PathVariable String upid,@PathVariable int rownum,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> fdn start", this.getClass().getSimpleName());
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        Pager pager=new Pager();
        pager.setEachPageRows(rownum);
        String selsql="select count(*) from T_Lbxx_Mx where processtype=? and userid=?";
        long c = DBUtil.count(selsql,upid,user.getUserloginid());
        pager.setTotalRows(c);
        request.setAttribute("upid", upid);
        request.setAttribute("totalPages", pager.getTotalPages() + "");
        request.setAttribute("totalRows", pager.getTotalRows() +"");
        return "portal/shd/initiateprocess";
    }

    /**
     * 获取没读信息
     * @return 结果
     */
    @RequestMapping(value = "/uc/shd/fdnv/initiateprocess/{upid}-{pages}({rownum})", method = RequestMethod.POST)
    public @ResponseBody String initiateprocesslist(@PathVariable String upid,@PathVariable int pages,@PathVariable int rownum,HttpServletRequest request) {
        debug("<<{}>> queryNewsPagesList start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        StringBuffer sb= new StringBuffer();
        String datetime="";
        List<TLbxxMx> list = Collections.EMPTY_LIST;
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String selsql="select wid,id,url,title,time,state,processtype,userid,db from T_Lbxx_Mx where processtype=? and userid=? order by time desc,db desc";
        Pager pager =new Pager();
        long c = DBUtil.count("select count(*) from ("+selsql+")",upid,user.getUserloginid());
        pager.setTotalRows(c);
        pager.setEachPageRows(rownum);
        pager.setCurrentPageno(pages);
        list = DBUtil.queryPageBeanList(pager,"select * from (" + selsql + ") where 1=1", TLbxxMx.class,upid,user.getUserloginid());
        if (list!=null&&list.size()>0) {
            for (int i = 0; i < list.size(); i++) {
                TLbxxMx tlbxxmx = list.get(i);
                if (tlbxxmx.getTime()!=null){
                    datetime= FORMAT_DATE.format(tlbxxmx.getTime());
                }else{
                    datetime="";
                }

                sb.append("<div class='li'>");
                if ("已完成".equals(tlbxxmx.getState())) {
                    sb.append("<label class='fq done'></label>");
                }else if ("处理中".equals(tlbxxmx.getState())){
                    sb.append("<label class='fq stop'></label>");
                }else{
                    sb.append("<label class='fq stop'></label>");
                }
                sb.append("<span onclick=\"gotoHtml('"+tlbxxmx.getUrl()+"')\"><a>" + tlbxxmx.getTitle() + "</a></span>");
                if ("oa".equals(tlbxxmx.getDb())) {
                    sb.append("<label class='xz'> OA办公 </label >");
                }else if ("hr".equals(tlbxxmx.getDb())){
                    sb.append("<label class='dz'> 人事 </label >");
                }else{
                    sb.append("<label class='hq'> 其他 </label >");
                }
                sb.append("<div class='time on'>" + datetime + "</div></div>");
            }
            if (list.size()<6){
                for (int i = list.size(); i <6; i++) {
                    sb.append("<div class='li'><span><a></a></span><div class='time on'></div></div>");
                }
            }
        }
        return sb.toString();
    }


    /**
     * 角色切换首页面
     * @return
     */
    @RequestMapping(value = "/uc/index/{type}", method = RequestMethod.GET)
    public synchronized String indexchange(@PathVariable String type,HttpServletRequest request) {
        try {
            TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
            initFwzx(request, type); //初始化通知公告
            initDyfw(request, type); //初始化订阅服务
            List <TMessage> ls_oa= getMessage(request,user,"unread","oa",5);
            List <TMessage> ls_hr= getMessage(request, user, "unread", "hr", 5);
            request.setAttribute("ls_oa", ls_oa);
            request.setAttribute("ls_hr", ls_hr);
            return "portal/shd/index_"+type;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_service_navigation, method = RequestMethod.GET)
    public String serviceNavigation(HttpServletRequest request, ModelMap map)throws IOException {
        //处理post中文问题
        request.setCharacterEncoding("UTF-8");
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String gjz=request.getParameter("gjz");
        String serviceids=request.getParameter("serviceids");
        if (StringUtil.isNotBlank(gjz)){
            gjz= URLDecoder.decode(gjz, "UTF-8");
        }
        request.setAttribute("gjz", gjz);
        request.setAttribute("serviceids", serviceids);
        String condition= " and exists (select 1 from t_service_menu m where m.menuid=t.menuid) and t.state='1' ";
        String sql_serach=" select t.*,nvl(s.unit,'暂无') as unit,nvl(s.workingtime,'暂无') as workingtime,nvl(s.workingplace,'暂无') as workingplace,nvl(s.contact,'暂无') as contact,s.rulesintroduced, " +
                " to_char((select wm_concat(c.zdmc) from t_service_code c where c.zdbm in (select m.serviceid from t_service_menu m where m.menuid=t.menuid) and c.zdlb='fwlb' )) as fwtype,"+
                " to_char((select nvl(avg(satisfaction),3) as satisfaction from T_Service_Satisfaction where menuid=t.menuid )) as score "+
                " from t_sys_menu t " +
                " left join T_SERVICE_INTRODUCD s on s.menuid=t.menuid"+
                " where 1=1  and t.menuid like '000603%' ";
        if (StringUtil.isNotBlank(gjz)){
            condition += " and t.menuname like '%"+gjz+"%'";
        }
        if (StringUtil.isNotBlank(serviceids)) {
            String[] serviceid=serviceids.split(",");
            for (int i=0;i<serviceid.length;i++) {
                condition += " and exists (select 1 from t_service_menu m where m.menuid=t.menuid and m.serviceid='" + serviceid[i] + "')";
            }
        }
        if (user!=null&&!"admin".equals(user.getUserloginid())) {
            condition+=     "      and  exists" +
                    "          (select 1" +
                    "           from t_sys_menu m" +
                    "           where m.bizcode = t.bizcode" +
                    "           and m.menuid in" +
                    "               (select m.menuid" +
                    "                  from t_sys_role_menu m" +
                    "                 where m.roleid in" +
                    "                       (select ur.roleid " +
                    "                        from t_sys_user_role ur" +
                    "                        where ur.userid in (select u.userid " +
                    " 													from t_sys_user u " +
                    " 													where u.userloginid = '" + user.getUserloginid() + "'))))";
        }
        sql_serach+=condition+" order by nlssort(t.menuname,'NLS_SORT=SCHINESE_PINYIN_M')";
        List<TSysMenu> menulist= DBUtil.queryAllBeanList(sql_serach, TSysMenu.class);
        request.setAttribute("resultList", menulist);
        return  ActionConstant.MhShd.Forward_service_navigation;
    }

    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_service_details, method = RequestMethod.GET)
    public String serviceDetails(@PathVariable String id,HttpServletRequest request, ModelMap map)throws IOException {
        //处理post中文问题
//       request.setCharacterEncoding("UTF-8");
        TSysMenu menu=new TSysMenu();
        List<TRegulation> tregulationList=null;
        if (StringUtil.isNotBlank(id)) {
            String condition = " and exists (select 1 from t_service_menu m where m.menuid=t.menuid) and t.state='1' ";
            String sql_serach = " select t.*,nvl(s.unit,'暂无') as unit,nvl(s.workingtime,'暂无') as workingtime,nvl(s.workingplace,'暂无') as workingplace," +
                    " nvl(s.contact,'暂无') as contact,s.rulesintroduced,s.attention," +
                    "(select c.zdmc from T_SYS_CODE c where c.zdbm=s.version and zdlb='version' ) as version, " +
                    " to_char((select wm_concat(c.zdmc) from t_service_code c where c.zdbm in (select m.serviceid from t_service_menu m where m.menuid=t.menuid) and c.zdlb='fwlb' )) as fwtype,"+
                    " to_char((select nvl(avg(satisfaction),3) as satisfaction from T_Service_Satisfaction where menuid=t.menuid )) as score "+
                    " from t_sys_menu t " +
                    " left join T_SERVICE_INTRODUCD s on s.menuid=t.menuid" +
                    " where 1=1 and t.menuid=?";
            sql_serach += condition + " order by nlssort(t.menuname,'NLS_SORT=SCHINESE_PINYIN_M')";
            List<TSysMenu> menulist= DBUtil.queryAllBeanList(sql_serach, TSysMenu.class,id);
            if (menulist!=null&&menulist.size()>0){
                menu=menulist.get(0);
            }
            tregulationList=getRegulations(id);//服务资源规则
            getProblomList(request, id);
            List<TSysCode> tsyscodeList =DBUtil.queryAllBeanList("select c.* from t_sys_code c where c.sfsy='1' and c.zdlb=? order by c.zdpx desc",TSysCode.class,"version");
            request.setAttribute("tsyscodeList", tsyscodeList);
        }
        request.setAttribute("menu", menu);
        request.setAttribute("id", id);
        request.setAttribute("regus", tregulationList);
        return  ActionConstant.MhShd.Forward_service_details;
    }

    /**
     * 获取服务资源规则
     *
     * @param menuid 服务id
     * @return
     */
    public List<TRegulation> getRegulations(String menuid) {
        debug("<<{}>> getRegulations start", this.getClass().getSimpleName());// 日志
        LittleTimer timer = new LittleTimer(); // 计时器
        try {
            String sql = "select t.* from t_regulation t left join t_regulation_gx r on t.wid = r.gzwid where r.zywid = ?";
            List<TRegulation> lists = DBUtil.queryAllBeanList(sql, TRegulation.class, menuid);
            return lists;
        } catch (Exception e) {
            error("<<{}>> getRegulations error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getRegulations end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 查询问题
     *
     * @param menuid 服务id
     */
    public void getProblomList(HttpServletRequest request, String menuid) {
        debug("<<{}>> getRegulations start", this.getClass().getSimpleName());// 日志
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        LittleTimer timer = new LittleTimer(); // 计时器
        List<TProblemNew> lists=null;
        String view_num= Const.PROBLEM_VIEW_NUMBER;
        try {
            String sql="";
            if (user!=null) {
                String userid=user.getUserloginid();
                if ("admin".equals(userid)) {
                    sql = "select t.* from t_PROBLEM t where t.sid = ? order by t.ptime desc ";
                    lists = DBUtil.queryAllBeanList("select * from ("+sql+" ）where rownum<="+view_num, TProblemNew.class, menuid);
                } else {
                    //一般用户可以查看自己或启用的问题
                    sql = "select t.* from t_PROBLEM t where （t.puser = ? or t.state=1) and t.sid = ? order by t.ptime desc";
                    lists = DBUtil.queryAllBeanList("select * from ("+sql+" ）where rownum<="+view_num,TProblemNew.class, userid, menuid);
                }
            }else{
                sql = "select t.* from t_PROBLEM t where t.state=1 and t.sid = ? order by t.ptime desc";
                lists=DBUtil.queryAllBeanList("select * from ("+sql+" ）where rownum<="+view_num, TProblemNew.class,menuid);
            }
            for (TProblemNew s : lists) {// 回复列表
                s.setAnspros(DBUtil.queryAllBeanList("select * from T_ANSWERPRO t  where t.pid = ? order by t.ptime desc", TAnswerPro.class, s.getWid()));
                s.setDiscusss(DBUtil.queryAllBeanList("select * from t_discuss t  where t.pid = ? order by t.dtime desc", TDiscuss.class, s.getWid()));
            }
            request.setAttribute("pros", lists);
        } catch (Exception e) {
            error("<<{}>> getProblomList error : {}", this.getClass().getSimpleName(), e); // 日志
            throw new RuntimeException(e);
        } finally {
            debug("<<{}>> getProblomList end : {}", this.getClass().getSimpleName(), timer.end());// 计算方法执行时间
        }
    }

    /**
     * 游客查看文章明细界面
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value =ActionConstant.MhShd.RequestMapping_news_details, method = RequestMethod.GET)
    public String queryNewsBeanfornotuser(@PathVariable String location,@PathVariable String wid,HttpServletRequest request, ModelMap map) {
        debug("<<{}>> queryNewsBean start", this.getClass().getSimpleName());
        LittleTimer timer = new LittleTimer();
        TWz twz = new TWz();
        TDb tdb =new TDb();
        String sql_fdn = " select t.wid,t.lmmc,(select code from t_db where wid=t.code) as code,t.querysql,t.weiz,t.shuom,t.state,t.updatesql" +
                " from T_FRONTDESK_NEWS t" +
                " where 1=1 and t.state=1 and t.weiz=? ";
        List<TFrontdeskNews> tfrontdesknewslist = DBUtil.queryAllBeanList(sql_fdn, TFrontdeskNews.class, location);
        if (tfrontdesknewslist != null && tfrontdesknewslist.size() > 0) {
            TFrontdeskNews tfrontdesknews = tfrontdesknewslist.get(0);
            request.setAttribute("tfrontdesknews", tfrontdesknews);
            String sql_new = tfrontdesknews.getQuerysql();
            String update_sql=tfrontdesknews.getUpdatesql();
            DBMUtil dbmUtil = new DBMUtil(tfrontdesknews.getCode());
            tdb =DBUtil.queryBean("select * from t_db where code=? and rownum<2" ,TDb.class,tfrontdesknews.getCode());
            if (StringUtil.isNotBlank(update_sql)){
                try {
                    int i =dbmUtil.executeSQL(update_sql,wid);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (tdb.getUrl().indexOf("sqlserver")!=-1){
                sql_new = " select * from (" + sql_new + " )  as t where wid=?";
            }else if(tdb.getUrl().indexOf("oracle")!=-1){
                sql_new = " select * from (" + sql_new + " ) where wid=?";
            }
            try {
                System.out.println("sql_new=" + sql_new);
                twz = dbmUtil.queryBean(sql_new, TWz.class, wid);
            } catch (Exception e) {
                System.out.println("E=" +e.toString());
                e.printStackTrace();
            }
        }
        request.setAttribute("twz", twz);
        return ActionConstant.MhShd.Forward_news_details;
    }

    /**
     * 游客查看文章明细界面
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value =ActionConstant.MhShd.RequestMapping_consulting, method = RequestMethod.GET)
    public String consulting(@PathVariable String wid,HttpServletRequest request, ModelMap map) {
        request.setAttribute("protypes", DBUtil.queryAllBeanList("select * from T_PROBLEMTYPE", TProblemType.class));//问题类型
        request.setAttribute("menuid", wid);
        return ActionConstant.MhShd.Forward_consulting;
    }

    /**
     * 查看咨询问题明细界面
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value =ActionConstant.MhShd.RequestMapping_questionReply, method = RequestMethod.GET)
    public String questionReply(@PathVariable String wid,HttpServletRequest request, ModelMap map) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String userid = user.getUserloginid();
        List<TProblemNew> lists;
        String sql= "select t.* from t_PROBLEM t where （t.puser = ? or t.state=1) and t.wid = ? order by t.ptime desc ";
        lists = DBUtil.queryAllBeanList(sql, TProblemNew.class,userid, wid);
        for (TProblemNew s : lists) {// 回复列表
            s.setAnspros(DBUtil.queryAllBeanList("select * from T_ANSWERPRO t  where t.pid = ? order by t.ptime desc", TAnswerPro.class, s.getWid()));
            s.setDiscusss(DBUtil.queryAllBeanList("select * from t_discuss t  where t.pid = ? order by t.dtime desc", TDiscuss.class, s.getWid()));
        }
        request.setAttribute("userid", userid);
        request.setAttribute("pros", lists);
        return ActionConstant.MhShd.Forward_questionReply;
    }

    /**
     * 首页用户收藏服务资源
     *
     * @param menuid    服务资源id
     * @param portletid 服务组件id
     * @param request   --
     * @return 服务资源id
     */
    @RequestMapping(value = ActionConstant.MhShd.RequestMapping_saveDy, method = RequestMethod.POST)
    @ResponseBody
    public String saveSc(@PathVariable(ActionConstant.Server.Variable_menuid) String menuid,
                         @PathVariable(ActionConstant.Variable_Portlet_Id) String portletid, HttpServletRequest request) {
        TSysUser tSysUser = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        String userid = tSysUser.getUserloginid();
        String id = SeqFactory.getNewSequenceAlone();
        String searchsql=" select count(*) " +
                " from t_sys_user u,t_sys_user_role b,t_sys_role c,t_sys_role_menu d " +
                " where u.userid=b.userid and b.roleid=c.roleid and c.roleid=d.roleid and d.menuid=?  and c.state=1 and u.userloginid=?";
        int num_search=DBUtil.count(searchsql,menuid,userid);
        if (num_search>0) {
            String sql = " insert into t_fw_dy(wid,fwid,userid,menuid) select ?,wid,?,? from t_fw fw" +
                    " where portletid=? and not exists (select null from t_fw_dy where fwid=fw.wid and userid=? and menuid=?)";
            int num_add=DBUtil.executeSQL(sql, id, userid, menuid, portletid, userid, menuid);
        }else{
            return "unauthorized";
        }
        return "ok";
    }

    /**
     * 事物
     *
     * @return 通知公告明细界面
     */
    @RequestMapping(value =ActionConstant.MhShd.RequestMapping_Transaction_issues, method = RequestMethod.GET)
    public String issues(@PathVariable String type,HttpServletRequest request, ModelMap map) {
        request.setAttribute("type", type);
        return ActionConstant.MhShd.Forward_Transaction_issues;
    }

    /**
     * 个人信息
     *
     * @return 个人信息界面
     */
    @RequestMapping(value =ActionConstant.MhShd.RequestMapping_Personal_information, method = RequestMethod.GET)
    public String pi(HttpServletRequest request, ModelMap map) {
        return ActionConstant.MhShd.Forward_Personal_information;
    }

    /**
     * 服务评价
     * @param request
     * @param serviceSatisfaction
     * @return
     */
    @RequestMapping(value = "/uc/shd/evaluation", method = RequestMethod.POST)
    public @ResponseBody String evaluation(HttpServletRequest request,TServiceSatisfaction serviceSatisfaction) {
        TSysUser user = (TSysUser) request.getSession().getAttribute(IdConstants.SESSION_USER);
        try {
           return  service.evaluation(request,user, serviceSatisfaction);
        } catch (Exception e) {
            error("<<{}>> init error : {}", this.getClass().getSimpleName(), e);
            throw new RuntimeException(e);
        }
    }
}
